package com.sc.VenusQueryBeta.presenter.login;

import com.hengjun.kingstar.sdk.utils.LogUtils;
import com.sc.VenusQueryBeta.contract.login.RegisterContract;
import com.sc.VenusQueryBeta.model.bean.login.RegisterVerticationBean;
import com.sc.VenusQueryBeta.model.login.RegisterModel;

import io.reactivex.functions.Consumer;

/**
 * Created by SC-02 on 2018/9/19.
 * 注册presenter 继承契约类的presenper
 */
public class RegisterPresenter extends RegisterContract.RegisterPresenter {
    public static RegisterPresenter newInstance(){
        return new RegisterPresenter();
    }
    @Override
    protected RegisterContract.IRegisterModel getModel() {
        return RegisterModel.newInstance();
    }

    @Override
    public void onStart() {

    }

    @Override
    public void getVerticatinCode(String clientUID, String deviceUID, String deviceType, String registerSmsnum, String areaCode, String flag) {
        mRxManager.register(mIModel.getVerticatinCode(clientUID, deviceUID, deviceType, registerSmsnum, areaCode, flag).subscribe(new Consumer<RegisterVerticationBean>() {
            @Override
            public void accept(RegisterVerticationBean registerVerticationBean) throws Exception {
//                if (mIView != null){
                LogUtils.e("registerVerticationBean.getRegisterSmsnum()=="+registerVerticationBean.getRegisterSmsnum());
//                    return;
//                }
                mIView.showVerticationDataSuccess(registerVerticationBean);
            }
        }, new Consumer<Throwable>() {
            @Override
            public void accept(Throwable throwable) throws Exception {
                LogUtils.e("accept");
//                if (mIView != null)
//                    return;
                mIView.showToast("Network error.");
                mIView.showNetworkError();
            }
        }));
    }
}
